package edu.zut.string;

public class StringBufferDemo {

    public static void main(String[] args) {
        //可变字符序列   默认空  默认初始容量16   自动扩容
        StringBuffer sb = new StringBuffer();
        StringBuffer sb2 = new StringBuffer("java");
        System.out.println(sb2);
        //定义一个可变字符串  初始容量 20
        StringBuffer sb3 = new StringBuffer(20);
        System.out.println(sb3 + "++++++");
        //append   追加
        sb2.append("!!!!");
        System.out.println(sb2);
        //指定修改
        sb2.setCharAt(0,'J');
        System.out.println(sb2);
        //插入
        sb2.insert(0,"hello ");
        System.out.println(sb2);

        //倒置操作
        System.out.println(sb2.reverse());

    }

}
